package com.sgb.goods.view.adapter;

import androidx.databinding.ViewDataBinding;

import com.chad.library.adapter.base.BaseViewHolder;
import com.sgb.goods.BR;
import com.sgb.goods.R;
import com.sgb.goods.databinding.GoodsItemOperationRecordBinding;
import com.sgb.goods.entity.MemberPriceEntity;
import com.sgb.goods.utils.base.adapter.BaseCommonAdapter;

public class OperationRecordAdapter extends BaseCommonAdapter<MemberPriceEntity.ItemMemberList> {

    public MemberPriceEntity.SkuMemberPriceList childItem;
    OnItemClickListener listener;

    public OperationRecordAdapter() {
        super(R.layout.goods_item_operation_record, BR.viewModel);
    }

    @Override
    protected void convert(BaseViewHolder baseHolder, ViewDataBinding dataBinding, MemberPriceEntity.ItemMemberList entity) {
        GoodsItemOperationRecordBinding mDataBinding = (GoodsItemOperationRecordBinding) dataBinding;

        BaseCommonAdapter<MemberPriceEntity.SkuMemberPriceList> adapter = new BaseCommonAdapter<>(R.layout.goods_item_operation_record_del, BR.viewModel);
        adapter.setNewData(entity.itemSkuMemberPriceList);
        mDataBinding.recyclerview.setAdapter(adapter);

        adapter.setOnItemClickListener((adapter1, view, position) -> {
            childItem = adapter.getItem(position);
            if(null != listener) {
                listener.onItemClick(OperationRecordAdapter.this, baseHolder.itemView, baseHolder.getLayoutPosition());
            }
        });
    }

    public void setItemChildClickListener(OnItemClickListener listener) {
        this.listener = listener;
    }
}
